<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
	p{
		border:1px solid red;
		width:250px;
		height:30px;
		line-height: 30px;
		text-align: center;
		font-size: 20px;
	}
	input{
		width:120px;
		height: 40px;
	}
</style>
<script type="text/javascript">
		var id;
	function send() {
		if(!confirm("确认发送!")){
			return;
		}
		
		if(id){
			return;
		}
		var msg_box=document.getElementById("msg");
			msg_box.innerHTML="正在发送...";
		id=setTimeout(function () {
			msg_box.innerHTML="成功发送...";
			alert("双11开抢了!准备好你的钞票!")
			console.log("成功!");
			id=null;
		}, 5000);
		
	}
	function cancel() {
		//只有定时器正在启动,才能将其停止
		if(!id){
			console.log("超时!");
			alert("撤回已超时!")
			return;
		}
		console.log(id);
		var msg_box=document.getElementById("msg");
		clearTimeout(id);
		id=null;
		msg_box.innerHTML="撤销发送...";
		console.log("已撤销.");
	}
</script>
</head>
<body>
	<input type="button" value="发送" onclick="send();"/>
	<input type="button" value="撤回" onclick="cancel();"/>
	<p id="msg">0.0</p>
</body>
</html>